from concurrent import futures
import time

import grpc

import grpc_test_pb2
import grpc_test_pb2_grpc

_ONE_DAY_IN_SECONDS = 60 * 60 * 24


class grpc_testServiceClsImpl(grpc_test_pb2_grpc.grpc_testServiceClsServicer):
    def grpc_test(self, request, context):
        return grpc_test_pb2.grpc_testResponse()
        # print(request.req)
        # return grpc_test_pb2.grpc_testResponse(res=request.req)


def serve():
    server = grpc.server(futures.ThreadPoolExecutor(max_workers=10))
    grpc_test_pb2_grpc.add_grpc_testServiceClsServicer_to_server(
        grpc_testServiceClsImpl(), server)
    server.add_insecure_port('[::]:50051')
    server.start()
    try:
        while True:
            time.sleep(_ONE_DAY_IN_SECONDS)
    except KeyboardInterrupt:
        server.stop(0)


if __name__ == '__main__':
    serve()
